#!/usr/bin/env python
# -*- coding: utf-8 -*-

from typing import Optional
from dataclasses import field
from marshmallow.validate import OneOf, Length, Validator
from marshmallow_dataclass import dataclass

from index.protocol import Field


@dataclass
class UpdateUserInfo:
    gender: Optional[str] = field(metadata=Field(validate=OneOf(choices=["1", "2"], error="只能使用{choices}")))
    signature: Optional[str] = field(metadata=Field(validate=Length(max=200, error="签名长度不能超过{max}个字符")))
    nickname: Optional[str] = field(metadata=Field(validate=Length(min=2, max=60, error="昵称最少{min}个字符，最多{max}个字符")))
    avatar: Optional[str]


@dataclass
class GetUserInfoResponse:
    user_id: int
    username: str
    gender: str = field(metadata=Field(validate=OneOf(choices=["1", "2"], error="只能使用: {choices}")))
    role: str
    register_time: str
    signature: str = ""
    nickname: str = ""
    avatar: str = ""


@dataclass
class ModifyPasswordRequest:
    old_password: str
    new_password: str = field(metadata=Field(validate=Length(min=6, max=100, error="密码长度为{min}到{max}个字符")))


@dataclass
class VerifyPasswordRequest:
    password: str
